<?php
class connect_db{
protected $host="localhost";
protected $user_host="root";
protected $pass_host="";
protected $dbname="db_gtvl";
protected $conn;
protected $result;
 
public function connect(){
	$this->conn=mysql_connect($this->host,$this->user_host,$this->pass_host);
	mysql_select_db($this->dbname,$this->conn);
}

public function disconnect(){
	if($this->conn){
		mysql_close($this->conn);
	}
}

public function query($sql){
	mysql_query("set names 'UTF8'"); 
	$this->result=mysql_query($sql);
}

public function num_rows(){
	if($this->result){
		$row=mysql_num_rows($this->result);
	}else{
		$row=0;
	}
	return $row;
}	

public function fetchone(){
	if($this->result){
		$row=mysql_fetch_assoc($this->result);
	}else{
		$row=0;
	}
	return $row;
}

public function fetchall(){
	if($this->result){
		while($row=mysql_fetch_assoc($this->result)){
			$data[]=$row;
		}
	}else{
		$data=0;
	}
	return $data;
}

}
